package org.linphone.Adapter;

import java.util.List;

import com.leehuubsd.yiyanzb.R;
import org.linphone.Bean.AppInfo;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AppManagerAdapter extends BaseAdapter {

	private List<AppInfo> list;
	private Context context;

	public AppManagerAdapter(List<AppInfo> list, Context context) {
		this.list = list;
		this.context = context;
	}

	public void setlists(List<AppInfo> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater layoutInflater = LayoutInflater.from(context);
		convertView = layoutInflater.inflate(R.layout.layout_appmanager_item,
				null);
		ImageView iv_app_icon = (ImageView) convertView
				.findViewById(R.id.iv_app_icon);
		TextView tv_app_name = (TextView) convertView
				.findViewById(R.id.tv_app_name);
		TextView tv_app_version = (TextView) convertView
				.findViewById(R.id.tv_app_version);
		AppInfo appInfo = list.get(position);
		iv_app_icon.setImageDrawable(appInfo.getIcon());
		tv_app_name.setText(appInfo.getName());
		tv_app_version.setText("版本:" + appInfo.getVersion());
		return convertView;
	}

}
